var appUtils = require ('./appUtils');
var clickUtils = require ('./clickUtils');
var logUtils = require ('./logUtils');
var ocrUtils = require ('./ocrUtils');
var randomUtils = require ('./randomUtils');
var swipeUtils = require ('./swipeUtils');
var textUtils = require ('./textUtils');
var timeUtils = require ('./timeUtils');
var fmtUtils = require ('./fmtUtils');
var pauseUtils = require ('./pauseUtils');
var configUtils = require ('./configUtils');
var ocrCharMap = require ('./ocrCharMap');

function existContent (content) {
  var TextUI = textUtils.existsTextStartsWith (content);
  if (TextUI) {
    return {
      type: 0,
      result: TextUI,
    };
  }
  var TextOCR = ocrUtils.captureExistsText (content);
  if (TextOCR) {
    return {
      type: 1,
      result: TextOCR,
    };
  }
  return null;
}
function existOneContent (contents) {
  if (!Array.isArray (contents)) {
    contents = [contents];
  }
  for (var index = 0; index < contents.length; index++) {
    var content = contents[index];
    var result = existContent (content);
    if (result) {
      return result;
    }
  }
  return false;
}
function clickContent (content, logError) {
  var result = false;
  var TextUI = textUtils.existsTextStartsWith (content);
  if (TextUI) {
    clickUtils.clickTextUI (TextUI);
    result = true;
    return result;
  }
  var TextOCR = ocrUtils.captureExistsText (content, logError);
  if (TextOCR) {
    clickUtils.clickTextOCR (TextOCR);
    result = true;
    return result;
  }
  return result;
}
function clickOneContent (contents) {
  if (!Array.isArray (contents)) {
    contents = [contents];
  }
  for (var index = 0; index < contents.length; index++) {
    var content = contents[index];
    if (clickContent (content)) {
      return true;
    }
  }
  return false;
}

exports.appUtils = appUtils;
exports.clickUtils = clickUtils;
exports.logUtils = logUtils;
exports.ocrUtils = ocrUtils;
exports.randomUtils = randomUtils;
exports.swipeUtils = swipeUtils;
exports.textUtils = textUtils;
exports.timeUtils = timeUtils;
exports.fmtUtils = fmtUtils;
exports.pauseUtils = pauseUtils;
exports.configUtils = configUtils;
exports.ocrCharMap = ocrCharMap;
exports.existContent = existContent;
exports.existOneContent = existOneContent;
exports.clickContent = clickContent;
exports.clickOneContent = clickOneContent;
